home *** CD-ROM | disk | FTP | other *** search
- -- card: 41536 from stack: in
- -- bmap block id: 0
- -- flags: 0000
- -- background id: 4755
- -- name:
-
-
- -- part 1 (field)
- -- low flags: 00
- -- high flags: 0007
- -- rect: left=30 top=78 right=296 bottom=478
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 0
- -- font id: 4
- -- text size: 9
- -- style flags: 0
- -- line height: 12
- -- part name:
-
-
- -- part contents for card part 1
- ----- text -----
- /*
- * FILE: person.c
- * AUTHOR: R.G.
- * CREATED: June 25, 1990
- *
- * define Person methods
- */
-
- # include "person.h"
- # include <stdio.h> /* declares printf(), scanf() */
- # include <string.h> /* declares strlen(), strcpy() */
- # include <stdlib.h> /* declares malloc(), free() */
-
- /******************************************************************
- * override init()
- ******************************************************************/
- int Person::init(void)
- {
- name = NULL; /* NULL pointer points "nowhere" */
- return 1;
- }
-
- /******************************************************************
- * set Person
- ******************************************************************/
- void Person::set(void)
- {
- char temp_name[80];
- int temp_age;
-
- printf("Enter name (no spaces):\n");
- scanf("%s",temp_name);
-
- /* malloc allocates space for string plus '\0' null character,
- * if available (else returns NULL):
- */
- name = malloc(sizeof(char) * (strlen(temp_name)+1));
- if (name != NULL)
- strcpy(name,temp_name); /* TC "shadowing" not needed since
- dynamic allocation was used */
-
- printf("Enter age:\n");
- scanf("%d",&temp_age); /* "shadowing" for TC safety */
- age = temp_age;
- }
-
- /******************************************************************
- * print Person
- ******************************************************************/
- void Person::print(void)
- {
- printf("Name: %s, Age: %d",name,age);
- }
-
- /******************************************************************
- * destroy Person
- ******************************************************************/
- int Person::destroy(void)
- {
- if (name != NULL)
- free(name); /* deallocate memory previously allocated */
- return 1;
- }
-
-
-
-
-
- -- part contents for background part 7
- ----- text -----
- 134
-
- -- part contents for background part 4
- ----- text -----
- File 4 of 7: